package com.zh.client.products.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.zh.pojo.Notice;
import com.zh.pojo.Products;
import com.zh.utils.PageModel;

import java.util.List;

public interface ProductsDao {

    List<Products> findproductByCategory(@Param("category") String category, @Param("pageModel") PageModel pageModel);

    int findproductCountByCategory(String category);

    List<Products> findproductByname(@Param("name") String name,@Param("pageModel") PageModel pageModel);

    int findproductByNameCount(String name);

    @Select("select * from products where id = #{id}")
    Products findProductById(String id);

    @Select("select * from notice order by n_time DESC limit 0,1")
    Notice findNotice();

    @Select("select products.id,products.name,products.imgurl,products.price,SUM(orderitem.buynum) totalnum " +
            "from products,orders,orderitem where orders.paystate = 1 and orders.ordertime > DATE_SUB(NOW()," +
            "INTERVAL 7 DAY) and orders.id = orderitem.order_id and products.id = orderitem.product_id group " +
            "by products.id order by totalnum DESC limit 0,2")
    List<Products> findWeekHotProduct();
}
